
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:s="http://www.sensap.eu/jsf"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:pe="http://primefaces.org/ui/extensions">

<!-- INTERFACE -->
<cc:interface>
	<cc:attribute name="id" />
	<cc:attribute name="graphModel" required="true" />
</cc:interface>

<!-- IMPLEMENTATION -->
<cc:implementation>
	<p:outputPanel
		rendered="#{empty cc.attrs.graphModel.selectedNode}"
		styleClass="ui-empty-message">
		<p:outputLabel value="#{messages.UI_PROPERTY_GRID_NO_NODE_SELECTED}" />
	</p:outputPanel>

	<p:outputPanel
		rendered="#{(!empty cc.attrs.graphModel.selectedNode) and 
                                                           (cc.attrs.graphModel.selectedNode.propertyDefinitions.isEmpty())}"
		styleClass="ui-empty-message">
		<p:outputLabel value="#{messages.UI_PROPERTY_GRID_NO_PROPERTIES}" />
	</p:outputPanel>

	<pe:dynaForm
		rendered="#{(!empty cc.attrs.graphModel.selectedNode) and 
                                                         (!cc.attrs.graphModel.selectedNode.propertyDefinitions.isEmpty())}"
		value="#{applicationDesignPageController.context.propertyEditorModel}"
		var="control" styleClass="table table-striped" style="width:100%">

		<pe:dynaFormControl type="StringList" for="stringList">
			<p:selectOneMenu id="stringList"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				required="#{control.required}">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
				<f:selectItem itemLabel="--" itemValue="#{null}"
					rendered="#{!control.required}" />
				<f:selectItems value="#{control.allowedValues}" />
			</p:selectOneMenu>
		</pe:dynaFormControl>
		<pe:dynaFormControl type="Date" for="date">
			<p:calendar id="date"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				required="#{control.required}" showOn="button"
				pattern="MM/dd/yyyy HH:mm">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</p:calendar>
		</pe:dynaFormControl>
		<pe:dynaFormControl type="String" for="string">

			<p:inputText id="string" style="display:none;" />

			<p:inputText rendered="#{!control.property.variable}"
				readonly="#{(!control.editable)}"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				required="#{control.required}">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</p:inputText>
			<p:inputText rendered="#{control.property.variable}" readonly="true"
				value="#{control.property.variableName}"
				required="#{control.required}">
			</p:inputText>

			<p:commandButton rendered="#{control.variablizable}"
				icon="ui-icon-tag" process="@this"
				update=":editVariableDialog:editVariableDialogForm"
				actionListener="#{editVariableDialogController.prepareDialog(cc.attrs.graphModel.selectedNode, control)}"
				onclick="windowBlockUI.block();"
				oncomplete="windowBlockUI.unblock();editVariableDialog.show();" />

		</pe:dynaFormControl>

		<pe:dynaFormControl type="Double" for="double">
			<p:inputText id="double" style="display:none;" />

			<pe:inputNumber rendered="#{!control.property.variable}"
				readonly="#{!control.editable}" decimalPlaces="5"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				required="#{control.required}" converter="javax.faces.Double">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</pe:inputNumber>

			<p:inputText rendered="#{control.property.variable}" readonly="true"
				value="#{control.property.variableName}"
				required="#{control.required}">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</p:inputText>
			<p:commandButton rendered="#{control.variablizable}"
				icon="ui-icon-tag" process="@this"
				update=":editVariableDialog:editVariableDialogForm"
				actionListener="#{editVariableDialogController.prepareDialog(cc.attrs.graphModel.selectedNode, control)}"
				onclick="windowBlockUI.block();"
				oncomplete="windowBlockUI.unblock();editVariableDialog.show();" />

		</pe:dynaFormControl>

		<pe:dynaFormControl type="Float" for="float">
			<p:inputText id="float" style="display:none;" />

			<pe:inputNumber rendered="#{!control.property.variable}"
				readonly="#{!control.editable}"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				decimalPlaces="2" required="#{control.required}"
				converter="javax.faces.Float">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</pe:inputNumber>

			<p:inputText rendered="#{control.property.variable}" readonly="true"
				value="#{control.property.variableName}"
				required="#{control.required}">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</p:inputText>
			<p:commandButton rendered="#{control.variablizable}"
				icon="ui-icon-tag" process="@this"
				update=":editVariableDialog:editVariableDialogForm"
				actionListener="#{editVariableDialogController.prepareDialog(cc.attrs.graphModel.selectedNode, control)}"
				onclick="windowBlockUI.block();"
				oncomplete="windowBlockUI.unblock();editVariableDialog.show();" />

		</pe:dynaFormControl>

		<pe:dynaFormControl type="Long" for="long">
			<p:inputText id="long" style="display:none;" />

			<pe:inputNumber rendered="#{!control.property.variable}"
				readonly="#{!control.editable}"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				required="#{control.required}" decimalPlaces="0"
				converter="javax.faces.Long">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</pe:inputNumber>

			<p:inputText rendered="#{control.property.variable}" readonly="true"
				value="#{control.property.variableName}"
				required="#{control.required}">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</p:inputText>
			<p:commandButton rendered="#{control.variablizable}"
				icon="ui-icon-tag" process="@this"
				update=":editVariableDialog:editVariableDialogForm"
				actionListener="#{editVariableDialogController.prepareDialog(cc.attrs.graphModel.selectedNode, control)}"
				onclick="windowBlockUI.block();"
				oncomplete="windowBlockUI.unblock();editVariableDialog.show();" />
		</pe:dynaFormControl>

		<pe:dynaFormControl type="Integer" for="integer">
			<p:inputText id="integer" style="display:none;" />

			<pe:inputNumber rendered="#{!control.property.variable}"
				readonly="#{!control.editable}"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				required="#{control.required}" decimalPlaces="0"
				converter="javax.faces.Integer">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</pe:inputNumber>

			<p:inputText rendered="#{control.property.variable}" readonly="true"
				value="#{control.property.variableName}"
				required="#{control.required}">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</p:inputText>
			<p:commandButton rendered="#{control.variablizable}"
				icon="ui-icon-tag" process="@this"
				update=":editVariableDialog:editVariableDialogForm"
				actionListener="#{editVariableDialogController.prepareDialog(cc.attrs.graphModel.selectedNode, control)}"
				onclick="windowBlockUI.block();"
				oncomplete="windowBlockUI.unblock();editVariableDialog.show();" />
		</pe:dynaFormControl>

		<pe:dynaFormControl type="Number" for="number">
			<p:inputText id="number" style="display:none;" />

			<pe:inputNumber rendered="#{!control.property.variable}"
				readonly="#{!control.editable}"
				value="#{cc.attrs.graphModel.selectedNode.propertyValueMap[control.valueKey]}"
				decimalPlaces="5" required="#{control.required}"
				converter="javax.faces.Number">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</pe:inputNumber>

			<p:inputText rendered="#{control.property.variable}" readonly="true"
				value="#{control.property.variableName}"
				required="#{control.required}">
				<p:ajax event="change" process="@this"
					update=":nodeGraphForm:nodeGraph" />
			</p:inputText>
			<p:commandButton rendered="#{control.variablizable}"
				icon="ui-icon-tag" process="@this"
				update=":editVariableDialog:editVariableDialogForm"
				actionListener="#{editVariableDialogController.prepareDialog(cc.attrs.graphModel.selectedNode, control)}"
				onclick="windowBlockUI.block();"
				oncomplete="windowBlockUI.unblock();editVariableDialog.show();" />

		</pe:dynaFormControl>

		<pe:dynaFormControl type="ArrayList" for="arrayList">
			<p:inputText id="arrayList" style="display:none;" />

			<p:commandButton icon="ui-icon-grip-dotted-horizontal"
				process="@this" update=":editGroupsDialog:editGroupsDialogForm"
				actionListener="#{editGroupsDialogController.prepareDialog(cc.attrs.graphModel.selectedNode, control)}"
				onclick="windowBlockUI.block();"
				oncomplete="windowBlockUI.unblock();editGroupsDialog.show();" />

		</pe:dynaFormControl>
	</pe:dynaForm>
</cc:implementation>
</html>
